/**
 * @param {string} s
 * @return {number}
 */
var romanToInt = function(s) {
    var obj = {
        "M" : 1000,
        "D" : 500,
        "C" : 100,
        "L" : 50,
        "X" : 10,
        "V" : 5,
        "I" : 1
    }

    var result = 0;

    for(var i = 0;i < s.length - 1;i++){
        var before = s[i];
        var after = s[i + 1];
        if(obj[before] >= obj[after]){
            result += obj[before]
        }else{
            result -= obj[after]
        }
    }
    var last = s[s.length - 1]
    result += obj[last]
    return result
};

var a = romanToInt("IV")
console.log(a);

console.log(undefined < 1)
